package com.hyacinth.repository.jpa;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * 基础持久层接口
 * Version: V1.0
 * Author: spring
 * Date: 2016/5/3
 */
@NoRepositoryBean
public interface BaseRepository<T extends Serializable, ID extends Serializable> extends JpaRepository<T, ID> {

    Optional<T> findByCode(Class<T> clazz, String code);
    /**
     * 返回id集合
     **/
    List queryIds(String sql) throws Exception;

    List queryObjs(String hql) throws Exception;

    List queryObjByPaging(String hql, long page, long pageSize, Map<String, Object> paramMap) throws Exception;

    List queryObj(String hql, Map<String, Object> paramMap) throws Exception;

    Long queryObjCount(String hql, Map<String, Object> params) throws Exception;

    @Transactional
    void batchInsert(List listA) throws Exception;
}
